### 分页模板函数，三个参数含义分别为：当前页、总页数，分页前方的链接

#define adminPaginate(Page, link)

#set(currentPage=Page.pageNumber??1)
#set(totalPage=Page.totalPage??1)
#set(totalRow=Page.totalRow??0)

#if(totalPage < 2 || currentPage > totalPage)
#return
#end

#setLocal(startPage = currentPage - 3)
#if(startPage < 1)
#setLocal(startPage = 1)
#end

#setLocal(endPage = currentPage + 3)
#if(endPage > totalPage)
#setLocal(endPage = totalPage)
#end

<nav data-pjax class="pagination justify-content-center">
    <ul class="pagination">
        #if(currentPage > 1)
        <li class="page-item pagination-first"><a data-pjax class="page-link" href="javascript:void(0);"
                                                  data-page="1#(append)"></a>
        </li>
        <li class="page-item pagination-prev"><a data-pjax class="page-link" href="javascript:void(0);"
                                                 data-page="#(currentPage - 1)#(append)">&lt;</a></li>
        #end
        #if(currentPage - 3 > 1)
        <li class="page-item"><a data-pjax class="page-link" href="javascript:void(0);"
                                 data-page="1#(append)">1</a></li>
        #end
        #for(i : [startPage..endPage])
        #if(currentPage == i)
        <li class="btn btn-success btn--icon waves-effect"><a style="color: white;" href="javascript:void(0);">#(i)</a>
        </li>
        #else
        <li class="page-item"><a data-pjax class="page-link" href="javascript:void(0);"
                                 data-page="#(i)#(append)">#(i)</a></li>
        #end
        #end
        #if(currentPage + 3 < totalPage)
        <li class="page-item"><a data-pjax class="page-link pointer" href="javascript:void(0);" style="overflow: hidden;
        text-overflow: ellipsis;white-space: nowrap;"
                                 data-page="#(totalPage)#(append)" title="#(totalPage)">#(totalPage)</a></li>
        #end
        #if(currentPage < totalPage)
        <li class="page-item pagination-next"><a data-pjax class="page-link" href="javascript:void(0);"
                                                 data-page="#(currentPage + 1)#(append)">&gt;</a></li>
        <li class="page-item pagination-last"><a data-pjax class="page-link" href="javascript:void(0);"
                                                 data-page="#(totalPage)#(append)"></a></li>
        #end
    </ul>
    <select onchange="func(this.options[this.options.selectedIndex].value)"
            style="height: 30px;margin-left: 20px;outline: none;border: 0; background: transparent;appearance:none;-webkit-appearance:none;-moz-appearance:none; ">
        <option value="10" #if(page.pageSize==10) selected #end>显示 10 条</option>
        <option value="20" #if(page.pageSize==20) selected #end>显示 20 条</option>
        <option value="30" #if(page.pageSize==30) selected #end>显示 30 条</option>
        <option value="45" #if(page.pageSize==45) selected #end>显示 45 条</option>
        <option value="100" #if(page.pageSize==100) selected #end>显示 100 条</option>
    </select>
    <p style="height: 30px;margin-top: 7px;margin-left: 20px;">共#(totalRow)条数据</p>
</nav>
<script>
    function func(a) {
        //获取被选中的option标签
        $('#p').val(1);
        $("#s").val(a);
        $("#jmisForm").submit();//分页使用表单提交
    }

    $(function ($) {
        var pageSize = #(page.pageSize);
        $('.pagination a[data-pjax]').click(function (event) {
            var pageNum = $(this).data().page;
            $('#p').val(pageNum);
            $("#s").val(pageSize);
            $("#jmisForm").submit();
        })
    });
</script>
#end
